package com.kun.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kun.dto.SysDictTypeDTO;
import com.kun.entity.SysDictType;
import com.kun.service.SysDictTypeService;
import com.kun.util.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author kun.li
 */
@RestController
@RequestMapping("dictType")
@RequiredArgsConstructor
@Tag(name = "字典类型管理")
public class SysDictTypeController {

    private final SysDictTypeService sysDictTypeService;

    @PostMapping("selectPage")
    @Operation(summary = "字典类型分页列表")
    public ResponseResult<Page<SysDictType>> selectPage(@RequestBody SysDictTypeDTO sysDictTypeDTO) {
        Page<SysDictType> sysParamPage = sysDictTypeService.page(Page.of(sysDictTypeDTO.getPage(), sysDictTypeDTO.getSize()));
        return ResponseResult.success(sysParamPage);
    }

    @PostMapping("save")
    @Operation(summary = "字典类型保存")
    public ResponseResult<Boolean> saveParam(@RequestBody SysDictType sysDictType) {
        return ResponseResult.success(sysDictTypeService.save(sysDictType));
    }


    @PostMapping("update")
    @Operation(summary = "字典类型修改")
    public ResponseResult<Boolean> updateParam(@RequestBody SysDictType sysDictType) {
        return ResponseResult.success(sysDictTypeService.updateById(sysDictType));
    }

    @DeleteMapping("delete")
    @Operation(summary = "字典类型删除")
    public ResponseResult<Boolean> deleteParam(@RequestBody List<String> ids) {
        return ResponseResult.success(sysDictTypeService.removeBatchByIds(ids));
    }


}
